#version 140

uniform sampler2D tex;

in vec2 TexCoord;
in vec3 Normal;

out vec4 FragColor;

void main()
{ 	
	// texturing
	vec4 texColor = texture2D(tex, TexCoord);
	if (texColor.a < 0.75) discard;
		
	// lighting
	vec3 n = normalize(Normal);
	vec3 lightDir = vec3(0,1,0);
	
	float ambient = 0.3;
	float diffuse = max(0.0, dot(n, lightDir ));
	FragColor = vec4(texColor.rgb * (ambient + diffuse), texColor.a*texColor.a );
}
